package fileSearchSystem;

import org.eclipse.swt.widgets.Text;

/**
 * This class (part of the MVC structure) calls the model function that
 * will search files according to tags query
 */
public class SearchExecuter 
{
	String searchString;
	SearchParser sp = SearchParser.getInstance();
	Text file_text;
	static private SearchExecuter instance = null;
	//for singleton
	private static Object someObject = new Object();
	
	private SearchExecuter(){}
	
	static public SearchExecuter getInstance() 
	{
		if(null == instance) 
		{
			//to insure that the time slice doesn't cause to creation of 2 instances
			synchronized (someObject) 
			{
				if (null == instance)
					instance = new SearchExecuter();
			}
		}
	    return instance;
	}
	
	/**
	 * The function call another function which process the query and insert the results to file_text
	 */
	public void execute()
	{
		sp.parseTagString(searchString, file_text);
	}

	/*set methods*/
	
	public void setSearchString(String searchString)
	{
		this.searchString = searchString;
	}
	
	public void setFile_text(Text file_text)
	{
		this.file_text = file_text;
	}
}
